fix(expressions): bound ancestor nullability in IsNull/NotNull binding - #4068
Open
dominikandreasseitz wants to merge 1 commit into
Open
dominikandreasseitz wants to merge 1 commit into
dominikandreasseitz wants to merge 1 commit into
Conversation
… nested fields BoundIsNull/BoundNotNull folded to AlwaysFalse()/AlwaysTrue() at bind time using only a field's own required flag. A required leaf field can still be absent from a row if an optional ancestor struct containing it is null, so plan_files() was silently dropping matching files once IsNull/NotNull hit a required field under an optional parent. Add Schema.is_field_required_in_path to walk the existing ancestor index and check the full path, and move the fold from BoundIsNull/BoundNotNull.__new__ into IsNull.bind()/NotNull.bind(), where the schema is already in scope. BoundReference and all other public signatures are unchanged. This mirrors Java's fix for the same bug (apache/iceberg#14270), which similarly reverted an earlier attempt to carry ancestor-nullability on the Accessor/BoundTerm itself (apache/iceberg#13804) in favor of a schema-level ancestor walk done only at bind time.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4067
Description
Fixes
IsNull/NotNullbinding silently dropping rows/files for a required field nested under an optional ancestor struct.Related iceberg java/rust PRs:
Bug:
BoundIsNull/BoundNotNull.__new__folded toAlwaysFalse()/AlwaysTrue()using only a field's ownrequiredflag.requiredleaf can still be absent if an optional ancestor struct containing it is nullplan_files()silently dropped matching files onceIsNull/NotNullhit a required field under an optional parent.Example:
New behavior:
IsNull/NotNullon a required field nested under an optional ancestor now correctly matches rows/files instead of silently pruning them.Change
pyiceberg/schema.py— addSchema.is_field_required_in_path(field_id), which walks the existing ancestor index to check the field and every ancestor is required. Mirrors Java'sTypeUtil.ancestorFields/allAncestorFieldsAreRequired.pyiceberg/expressions/__init__.py— remove the leaf-only fold fromBoundIsNull/BoundNotNull.__new__; do the fold inIsNull.bind()/NotNull.bind()instead, matching where Java does it (UnboundPredicate.bindUnaryOperation) — no change toBoundReference.tests/test_schema.py,tests/expressions/test_expressions.py— coverage for the fix.